<template>
    <div id="member">
        <el-col :span="24" class="action-bar">
            <!-- <aaa :ccc="ccc">
                <template  v-slot:haha="scope" >{{scope.ccc.d}}</template>
            </aaa> -->
            <el-input v-model="searchText" placeholder="用户昵称或手机号" style="width:300px"></el-input>
            <el-select v-model="userType" clearable placeholder="用户类型" style="margin:0 20px;">
                <el-option
                v-for="item in userTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select>
            <el-select v-model="accountStatus" clearable placeholder="账号状态" style="margin:0 20px;">
                <el-option
                v-for="item in accountStatusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select>
            <el-select v-model="circleType" clearable placeholder="圈子类型" style="margin:0 20px;">
                <el-option
                v-for="item in circleTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select>

                <el-button type="primary" size="medium" @click="search">筛选</el-button>
            </el-col>
        <el-col class="action-bar screen">
                    <el-checkbox label="个性签名" name="signature" v-model="showColumns.signature"></el-checkbox>
                    <el-checkbox label="用户类型" name="usersType" v-model="showColumns.usersType"></el-checkbox>
                    <el-checkbox label="账号状态" name="account" v-model="showColumns.account"></el-checkbox>
                    <el-checkbox label="注册时间" name="createdAt" v-model="showColumns.createdAt"></el-checkbox>
            </el-col>

        <!-- 列表 -->
        <el-table
            :data="tableData"
            style="width: 100%">
            <el-table-column
                prop="date"
                label="头像"
                width="100">
                <template slot-scope="scope">
                    <div v-if="scope.row.user_info">
                        <img :src="scope.row.user_info.photo_url" alt="" style="width:60px;border-radius:50%;height:60px;object-fit:cover">
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                prop="name"
                label="姓名/昵称"
                width="180">
                <template slot-scope="scope" v-if="scope.row.user_info">
                    <div>{{scope.row.user_info.realname?scope.row.user_info.realname:scope.row.user_info.nickname}}</div>
                </template>
            </el-table-column>
            <el-table-column
                prop="phone"
                label="手机"
                width="120"
                >
            </el-table-column>
            <el-table-column
                prop="sex_name"
                width="80"
                label="性别">
                <template slot-scope="scope">
                    <div v-if="scope.row.user_info">
                        <div v-show="scope.row.user_info.sex==0">保密</div>
                        <div v-show="scope.row.user_info.sex==1">男</div>
                        <div v-show="scope.row.user_info.sex==2">女</div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                prop="status_name"
                label="个性签名"
                width="120"
                v-if="showColumns.signature"
                >
                <template slot-scope="scope">
                    <el-button type="primary" @click="showSignature">查看</el-button>
                </template>
            </el-table-column>
            <el-table-column
                prop="score"
                width="100"
                v-if="showColumns.usersType"
                label="用户类型">
            </el-table-column>
            <el-table-column
                prop="address"
                label="账号状态"
                v-if="showColumns.account"
                width="100"
                >
            </el-table-column>
            <el-table-column
                prop="created_at"
                label="注册时间"
                v-if="showColumns.createdAt"
                width="200"
                >
            </el-table-column>
            <el-table-column
                prop="status_name"
                label="个性签名"
                show-overflow-tooltip
                width="100"
                >
                <template slot-scope="scope">
                    <div v-if="scope.row.user_info">
                        {{scope.row.user_info.signature}}
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="操作" width='143'>
                <template slot-scope="scope">
                    <el-select v-model='scope.row.operation' style='width: 120px' placeholder="请选择操作">
                    <el-option value='禁言'><el-button type='text' @click="forbiddenWords(scope.row.id,true)">禁言</el-button></el-option>
                    <el-option value='取消禁言'><el-button type='text' @click="forbiddenWords(scope.row.id,false)">取消禁言</el-button></el-option>
                    <el-option value='放出小黑屋'><el-button type='text' @click="toBlack(scope.row.id,true)">放出小黑屋</el-button></el-option>
                    <el-option value='加入小黑屋'><el-button type='text' @click="toBlack(scope.row.id,false)">加入小黑屋</el-button></el-option>
                    <el-option value='封号'><el-button type='text' @click="bannedPost(scope.row.id,true)">封号</el-button></el-option>
                    <el-option value='取消封号'><el-button type='text' @click="bannedPost(scope.row.id,false)">取消封号</el-button></el-option>
                    <el-option value='积分明细'><el-button class='warning' type='text' @click="showIntegration(scope.row.id)">积分明细</el-button></el-option>
                    <el-option value='设置用户'><el-button class='warning' type='text' @click="toSetCustomer(scope.row.id)">设置用户</el-button></el-option>
                    </el-select>
                </template>
            </el-table-column>
            
        </el-table>
        <el-col :span="24" class="footer-bar">
			<div class="page-code">
				<el-pagination
					background
					:page-size="16"
					layout="prev, pager, next"
					:total="totalPage"
					@current-change="pageChange"
						>
				</el-pagination>
			</div>
    </el-col>
    <!-- 列表end -->

        <!-- 签名弹窗 -->
		<el-dialog title="个性签名" :visible.sync="signatureVisible" @close="initData">
            <div>这是签名11111</div>
		</el-dialog>
        <!-- 签名弹窗end -->

        <!-- 签名弹窗 -->
		<el-dialog title="积分明细" :visible.sync="integrationVisible" @close="initData">
            <div>这是明细11111</div>
		</el-dialog>
        <!-- 签名弹窗end -->

        <!-- 设置用户类型 -->
		<el-dialog title="设置用户类型" :visible.sync="userTypeVisible" @close="initData">
            <el-form>
                <el-form-item label="设置用户类型">
                    <el-select v-model="setUserType" clearable placeholder="用户类型" style="margin:0 20px;">
                        <el-option
                        v-for="item in userTypeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                
            </el-form>
            <div slot="footer" class="dialog-footer">
                    <el-button type="primary">提交</el-button>
                </div>
		</el-dialog>
        <!-- 设置用户类型end -->

    </div>
</template>
<script>import aaa from '@/components/aaa';
export default {
    components:{aaa},
    name:'member',
    data() {
        return {
            ccc:{
                c:'haha',
                d:"cici"
            },
            signatureVisible:false,//查看个性签名弹窗状态
            integrationVisible:false,//积分明细弹窗
            searchText:'',
            operation:'',//选中的操作
            userTypeId:'',//选中的用户id

            userType:'',//头部筛选的用户类型
            userTypeOptions:[
                {label:'全部',value:0},
                {label:'普通用户',value:1},
                {label:'认证用户',value:2},
                {label:'圈主',value:3},
                {label:'官方用户',value:4}
            ],

            accountStatus:'',//头部筛选的账号状态
            accountStatusOptions:[
                {label:'全部',value:0},
                {label:'正常',value:1},
                {label:'封号',value:2}
            ],
            showColumns:{
                signature:false,//签名
                account:false,//用户类型
                createdAt:false,//注册时间
                usersType:false//用户类型
            },
            circleType:'',//头部筛选的用户类型
            circleTypeOptions:[
                {label:'圈1',value:0},
                {label:'圈2',value:1},
            ],

            setUserType:'',//弹窗设置的用户类型
            userTypeVisible:false,//设置用户类型弹窗
            tableData: [{}],
            page:1,
            totalPage:0    
        }
    },
    watch: {

    },
    methods: {
        search(){
            this.page=1;
            this.getUserList()
        },
        async getUserList(){
            //获取会员列表
            let params={
                page:this.page,
                limit:16,
                keyword:this.searchText
            }
            let res=await this.$api.getUserList(
                params);
            if(res.data.level=='success'){
                this.tableData=res.data.data;
                this.totalPage=res.data.page_info.total;
            }
        },
        pageChange(e){
			//翻页
			this.page=e;
			this.getUserList();
        },
        async forbiddenWords(id,flag){
            //禁言
            let judge=null;
            let tit=flag?'对该用户禁言?':'取消该用户的禁言?';
            
            try {
              judge=  await this.$confirm(tit, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
                })
            } catch (error) {
                judge='cancel'
            }
            console.log(judge)
        },
        async toBlack(id,flag){
            //加入小黑屋
            let judge=null;
            let tit=flag?'把该用户扔进小黑屋?':'把该用户扔出小黑屋?';
            try {
              judge=  await this.$confirm(tit, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
                })
            } catch (error) {
                judge='cancel'
            }
            console.log(judge)
        },
        async bannedPost(id,flag){
            //封号
            let judge=null;
            let tit=flag?'对该用户进行封号?':'取消该用户的封号??';
            try {
              judge=  await this.$confirm(tit, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
                })
            } catch (error) {
                judge='cancel'
            }
            console.log(judge)
        },
        showIntegration(){
            //显示积分明细
            this.integrationVisible=true
        },
        showSignature(){
            //显示签名
            this.signatureVisible=true
        },
        toSetCustomer(){
            //设置账号
            this.userTypeVisible=true
        },
        initData(){

        }

    },
    mounted() {
        this.getUserList()
    },
}
</script>
<style lang="scss" scoped>
    .screen{
          margin-top: -10px !important;
      }
    .action-bar{
			background-color: #f2f2f2;
			height: 60px;
			margin: 10px 0px;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			padding-left: 20px;
			.action-bar-input{
				width: 250px;
				margin-right: 14px;
      }
      .task-form-text{
				color: #666666;
			}
		}
		.el-table-style{
			width: 100%;
			border: 1px solid #f2f2f2;
		}
		.footer-bar{
			display: flex;
			justify-content: space-between;
			align-items: center;
			background: #f2f2f2;
			padding: 8px;
			margin: 10px 0px;
			box-sizing: border-box;
		}
		.dialog-footer{
			text-align: center;
		}
		.executorList{
			display: flex;
			flex-wrap: wrap;
			div{
				margin:10px;
				border:1px solid #eee;
				border-radius: 5px;
				padding:5px 10px;
			}
		}
</style>